﻿using BenCaoXuan.Infrastructure.Attr;
using BenCaoXuan.Infrastructure.Dto;
using BenCaoXuan.Infrastructure.Dto.Admin.Appointment;
using BenCaoXuan.Service.Interface.admin;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BenCaoXuan.Api.Admin.Controllers.admin
{
    [ApiGroup("Admin(管理端模块)")]
    public class AppointmentController : BaseController
    {
        private readonly I_Appointment_Service _appointment_Service;

        public AppointmentController(I_Login_Service login_Service, I_Appointment_Service appointment_Service) : base(login_Service)
        {
            _appointment_Service = appointment_Service;
        }


        /// <summary>
        /// 管理端-获取所有预约
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="kry"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Appointment(int page=1,int limit=10,string? key="",string? productId="") {
            var result = await _appointment_Service.Get_Appointment(new Fenye_Dto() { 
            id=productId,
            key=key??"",
            limit=limit,
            page=page
            });
            return Ok(result);
        }

        /// <summary>
        /// 管理端-编辑预约
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Update_Appointment(UpdateAppointment_Dto dto) {
            var result = await _appointment_Service.Update_Appointment(dto);
            return Ok(result);
        }

        /// <summary>
        /// 管理端-取消预约
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> CancelAppointment(IsBan_Dto dto) {
            var result = await _appointment_Service.Cancel_Appointment(dto);
            return Ok(result);
        }

        /// <summary>
        /// 管理端-获取预约的静态数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Appointment_StatisticsData() {
            var result = await _appointment_Service.Get_Appointment_StatisticsData();
            return Ok(result);
        }


    }
}
